package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.YzrPharStock;

public interface IYzrPharStockDAO2 extends CrudRepository<YzrPharStock, String> {

	@Query("select max(yps.pharStockId) from YzrPharStock yps where yps.pharStockId like ?1%")
	public String findMaxId(String a);
	
	//判断库存是否存在
	@Query("select yps from YzrPharStock yps where yps.pharStockMedId=?1 and yps.pharStockBatchnumber=?2")
	public YzrPharStock findByMedicine(String medId, String batchNumber);
	
	@Query("select yps from YzrPharStock yps where yps.pharStockMedId=?1")
	public List<YzrPharStock> findPiHaoByMedId(String medId);
	
	
	//分页查询
	@Query("select yps from YzrPharStock yps order by yps.pharStockId desc")
	public List<YzrPharStock> findAllByPage(Pageable pageable);
	
	@Query("select yps from YzrPharStock yps where yps.pharStockMedName like %?1% order by yps.pharStockId desc")
	public  List<YzrPharStock> findMedByMedName(String medName,Pageable pageable);
}
